package com.mh.domain;

import java.io.Serializable;

import java.lang.StringBuilder;

import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.*;

import javax.persistence.*;

import org.hibernate.validator.constraints.NotEmpty;

/**
 * 
 * @ModelCoreReference [platform:/resource/demo-mh/.springDSL/com/mh/domain/AppUserRole.datatype]
 */

@Entity
@NamedQueries({
		@NamedQuery(name = "findAllAppUserRoles", query = "select myAppUserRole from AppUserRole myAppUserRole"),
		@NamedQuery(name = "findAppUserRoleByApplication", query = "select myAppUserRole from AppUserRole myAppUserRole where myAppUserRole.application = ?1"),
		@NamedQuery(name = "findAppUserRoleByApplicationContaining", query = "select myAppUserRole from AppUserRole myAppUserRole where myAppUserRole.application like ?1"),
		@NamedQuery(name = "findAppUserRoleById", query = "select myAppUserRole from AppUserRole myAppUserRole where myAppUserRole.id = ?1"),
		@NamedQuery(name = "findAppUserRoleByPrimaryKey", query = "select myAppUserRole from AppUserRole myAppUserRole where myAppUserRole.id = ?1"),
		@NamedQuery(name = "findAppUserRoleByRoleName", query = "select myAppUserRole from AppUserRole myAppUserRole where myAppUserRole.roleName = ?1"),
		@NamedQuery(name = "findAppUserRoleByRoleNameContaining", query = "select myAppUserRole from AppUserRole myAppUserRole where myAppUserRole.roleName like ?1"),
		@NamedQuery(name = "findAppUserRoleByUserName", query = "select myAppUserRole from AppUserRole myAppUserRole where myAppUserRole.userName = ?1"),
		@NamedQuery(name = "findAppUserRoleByUserNameContaining", query = "select myAppUserRole from AppUserRole myAppUserRole where myAppUserRole.userName like ?1") })
@Table(schema = "MHTEST", name = "APP_USER_ROLE")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(namespace = "demo-mh/com/mh/domain", name = "AppUserRole")
public class AppUserRole implements Serializable {
	private static final long serialVersionUID = 1L;

	/**
	 */

	@Column(name = "ID", nullable = false)
	@Basic(fetch = FetchType.EAGER)
	@Id
	@XmlElement
	@SequenceGenerator(name = "seq_app_user_role", sequenceName = "seq_app_user_role")
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seq_app_user_role")
	@NotNull
	Integer id;

	/**
	 */

	@Column(name = "USER_NAME", length = 30, nullable = false)
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	@NotNull
	@NotEmpty
	@Size(max=30,  message="{com.vit.tamanho.maximo}")
	String userName;

	/**
	 */

	@Column(name = "APPLICATION", length = 20, nullable = false)
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	@NotNull
	@NotEmpty
	@Size(max=20,  message="{com.vit.tamanho.maximo}")
	String application;

	/**
	 */

	@Column(name = "ROLE_NAME", length = 60, nullable = false)
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	@NotNull
	@NotEmpty
	@Size(max=60,  message="{com.vit.tamanho.maximo}")
	String roleName;

	/**
	 */
	public void setId(Integer id) {
		this.id = id;
	}

	/**
	 */

	public Integer getId() {
		return this.id;
	}

	/**
	 */
	public void setUserName(String userName) {
		this.userName = userName;
	}

	/**
	 */
	public String getUserName() {
		return this.userName;
	}

	/**
	 */
	public void setApplication(String application) {
		this.application = application;
	}

	/**
	 */
	public String getApplication() {
		return this.application;
	}

	/**
	 */
	public void setRoleName(String roleName) {
		this.roleName = roleName;
	}

	/**
	 */
	public String getRoleName() {
		return this.roleName;
	}

	/**
	 */
	public AppUserRole() {
	}

	/**
	 * Copies the contents of the specified bean into this bean.
	 *
	 */
	public void copy(AppUserRole that) {
		setId(that.getId());
		setUserName(that.getUserName());
		setApplication(that.getApplication());
		setRoleName(that.getRoleName());
	}

	/**
	 * Returns a textual representation of a bean.
	 *
	 */
	public String toString() {

		StringBuilder buffer = new StringBuilder();

		buffer.append("id=[").append(id).append("] ");
		buffer.append("userName=[").append(userName).append("] ");
		buffer.append("application=[").append(application).append("] ");
		buffer.append("roleName=[").append(roleName).append("] ");

		return buffer.toString();
	}

	/**
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = (int) (prime * result + ((id == null) ? 0 : id.hashCode()));
		return result;
	}

	/**
	 */
	public boolean equals(Object obj) {
		if (obj == this)
			return true;
		if (!(obj instanceof AppUserRole))
			return false;
		AppUserRole equalCheck = (AppUserRole) obj;
		if ((id == null && equalCheck.id != null) || (id != null && equalCheck.id == null))
			return false;
		if (id != null && !id.equals(equalCheck.id))
			return false;
		return true;
	}
}
